package com.lyz.dataStructure.xiancheng.读写锁;/**
 * @Author:759057893@qq.com Lyz
 * @Date: ${Date} 11:46
 * @Description:
 **/

/**
 *@Author:759057893@qq.com Lyz
 *@Date: 2019/8/27 11:46
 *@Description:
 **/
public class Writer implements Runnable {
    private ReadWriteLockTest pricesInfo;

    public Writer(ReadWriteLockTest pricesInfo) {
        this.pricesInfo = pricesInfo;
    }

    @Override
    public void run() {
        for (int i = 0; i < 3; i++) {
            System.out.printf("Writer: Attempt to modify the prices.\n");
            pricesInfo.setPrices(Math.random() * 10, Math.random() * 8);
            System.out.printf("Writer: Prices have been modified.\n");
            try {
                Thread.sleep(2);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }
    }
}